import request from './request'
import { useUserStore } from "../store/modules/user"
// 获取角色列表
export function getRoleList(data: object) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/system/role/getList',
        method: 'post',
        data,
        headers: token
    })
}

// 批量启用或禁用角色状态
export function changeRole(data: any, params: { status: boolean }) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/system/role/disable',
        method: 'put',
        data,
        params,
        headers: token
    })
}

// 批量删除角色
export function deleRole(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/system/role/',
        method: 'delete',
        data,
        headers: token
    })
}

// 新增或修改角色权限
export function saveRole(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/system/role/save',
        method: 'post',
        data,
        headers: token
    })
}
// 获取所有菜单权限
export function getAllAuthor() {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/system/customer/author/getAllAuthor',
        method: 'get',
        headers: token
    })
}
// 根据角色ID获取角色权限
export function getRoleAuthor(id) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/system/role/getRoleAuthor/'+id,
        method: 'get',
        headers: token
    })
}
// 保存角色权限
export function saveRoleAuthor(data: any,id) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/system/role/saveRoleAuthor/'+id,
        method: 'post',
        data,
        headers: token
    })
}
// 根据账号获取菜单权限
export function getAuthors() {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/system/role/getAuthors',
        method: 'get',
        headers: token
    })
}